package com.zkny.zknyerp.utils;

import org.apache.shiro.authc.AuthenticationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常捕获类
 */
@RestControllerAdvice
public class MyExceptionHandler {

    //shiro用户名和密码不匹配
    @ExceptionHandler(value = AuthenticationException.class)
    public Result uthenticationExceptionHandler(Exception e){
        return new Result(Constant.code_1001, Constant.msg_1001);
    }

    //其他异常捕获
    @ExceptionHandler(value = Exception.class)
    public Result exceptionHandler(Exception e){
        return new Result(Constant.code_9999, Constant.msg_9999);
    }
}
